package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.battle.module.record.Record;
import yxy.cherry.battle.module.record.stream.RecordStreamGroup;
import yxy.cherry.battle.module.record.stream.RecordStream_24_怒气变化;
import yxy.cherry.battle.module.record.stream.RecordStream_SKL;
import yxy.cherry.data.bean.skill;

/** 怒气 */
@SkillType(Type = SkillTypeEnum.怒气)
public class Affix_20_怒气 extends Skill {

	private int get增减值() {
		return getParam(0);
	}

	public Affix_20_怒气(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	private RecordStreamGroup steamGroup;

	@Override
	public RecordStreamGroup record() {
		Record record = getRecord();
		steamGroup = record.stream(new RecordStreamGroup());
		steamGroup.add(new RecordStream_SKL(getActor(), getSkillId()));
		return steamGroup;
	}

	@Override
	public boolean exec(Fighter actor, Fighter target) {
		if(!target.is活着()){
			return false;
		}

		int 增减值 = get增减值();
		if (增减值 == 0) {
			return false;
		}

		if (增减值 < 0) {
			if (target.getAnger() + 增减值 < 0) {
				target.initAnger(0);
			} else {
				target.initAnger(target.getAnger() + 增减值);
			}
		} else {
			target.add怒气(增减值);
		}

		getAffixContext().add怒气变动武将(target);

		// 流脚本
		steamGroup.add(new RecordStream_24_怒气变化(target, 增减值)).record();
		Battle.battleLogger(6,"怒气：目标"+target.getName()+"怒气增减值："+增减值);

		return true;
	}
}